# -*- coding: utf-8 -*-
import scrapy
from siwi.items import Id97DemoItem
class Id97Spider(scrapy.Spider):
    name = 'id97'
    allowed_domains = ['www.id97.com']
    start_urls = ['http://www.id97.com/movie/']

    def parse(self, response):
        for sel in response.xpath('//div[@class="movie-item-in"]'):
            item = Id97DemoItem()
            item['articleUrl'] = sel.xpath('a/@href').extract_first();
            item['moveNmae'] = sel.xpath('div[@class="meta"]/h1/a/text()').extract_first();
            item['scoreNumber'] = sel.xpath('div[@class="meta"]/h1/em/text()').extract_first();
            item['style'] = sel.xpath('div[@class="meta"]/div[@class="otherinfo"]/a/text()').extract();
            item['thumbUrl'] = sel.xpath('a/img/@data-original').extract_first();
            yield item;
        next_page = response.xpath('//ul[@class="pagination pagination-sm"]/li[last() -1]/a/@href').extract_first()
        url = response.urljoin(next_page);
        #yield scrapy.Request(url, self.parse)